﻿#ifndef _OI_PLSCANNERCORE_ERROR_HPP_
#define _OI_PLSCANNERCORE_ERROR_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        class OI_PLSCANNER_CORE_API PLScannerError
        {
        public:
            PLScannerError();

        public:
            enum ErrorCode
            {
                ERR_UNKOWN = 0,
                ERR_MODBUS_INVALID,
                ERR_MODBUS_READ_TIMEOUT,
                ERR_MODBUS_WRITE_TIMEOUT,
                ERR_CAMERA_OPEN_FAILED,
                ERR_CALIB_INFO,
                ERR_DONGLE,
                ERR_CAPTURE_TIMEOUT,
                ERR_FILE_LOAD_FAILED,
                ERR_CACULATE_RESULT_OVERFLOW,
                ERR_TASK_OVERFLOW,
                ERR_DATEBASE_OPEN_FAILED,
                ERR_PLC_INVALID,
                ERR_PLC_TIMEOUT,
                ERR_OPC_CREATE_FAILED,
                ERR_OPC_ITEMS_APPEND_FAILED,
                ERR_OPC_READ_TIMEOUT,
                ERR_OPC_WRITE_TIMEOUT,
                ERR_ETHERNET_DISCONNECTED,
                ERR_ETHERNET_INVAILD,

            };

        public:
            QList<QString> ErrorStr
            {
                QObject::tr("未知错误"),
                QObject::tr("Modbus 连接失败"),
                QObject::tr("Modbus 读取超时"),
                QObject::tr("Modbus 写入超时"),
                QObject::tr("传感器打开失败"),
                QObject::tr("标定失败"),
                QObject::tr("加密狗信息不正确"),
                QObject::tr("数据采集超时"),
                QObject::tr("工程加载失败"),
                QObject::tr("计算结果堵塞"),
                QObject::tr("任务堵塞，任务失败"),
                QObject::tr("数据库打开失败"),
                QObject::tr("PLC 连接失败"),
                QObject::tr("PLC通信失败"),
                QObject::tr("OPC创建失败"),
                QObject::tr("OPC通信项错误"),
                QObject::tr("OPC读失败"),
                QObject::tr("OPC写失败"),
                QObject::tr("传感器通信未连接"),
                QObject::tr("传感器通信异常"),
            };

        public:
            static PLScannerError* instance();

        public:
            void reportError(const ErrorCode);
            void clearError(const ErrorCode);

        private:
            OI_DISABLE_COPY(PLScannerError);
            OI_DECLARE_IMPL(PLScannerError);
        };
    }
}

#endif
